<%--
  Created by IntelliJ IDEA.
  User: jcl
  Date: 2020/8/18
  Time: 15:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>定级列表-院学术委员会秘书处</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
</head>
<style>
    .btn{
        float: right;
    }
    #tableBox .layui-table-cell .layui-form-checkbox[lay-skin=primary] {
        top: 5px!important;
    }
</style>
<body>
<div>
    <div class="item">
        <img src="../img/chengguo.png" alt="" style="margin: 0 5px 0 20px;"> <span
            style="font-size: 22px;display: inline-block;vertical-align: middle;">定级列表(院学术委员会秘书处)</span>
    </div>
    <hr  class="layui-bg-blue">
    <div style="height: 30px;">
        <div class="btn">
            <button type="button" class="layui-btn immp layui-btn-sm " id="export" style="margin-right: 15px" >
                <i class="layui-icon">&#xe601;</i>
                导出
            </button>
            <button type="button" class="layui-btn add layui-btn-sm " id="commit" style="margin-right: 15px" >
                确定名单
            </button>
        </div>
    </div>
    <div id="tableBox" class="layui-tab layui-tab-card"  lay-filter="tabGolle">
        <ul class="layui-tab-title" id="ulBox">
            <li num="1" class="layui-this">未确定</li>
            <li num="2">已确定</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <table class="layui-hide" id="Settlement" lay-filter="SettlementFilter"></table>
            </div>
            <div class="layui-tab-item">
                <table class="layui-hide" id="noSettlement" lay-filter="noSettlementFilter"></table>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">审核</a>
    <a class="layui-btn layui-btn-xs" lay-event="look">查看</a>
</script>
<script>
    var settlementTable;
    var nosettlementTable;
    layui.use(['table','layer','laydate','upload','form','element'], function(){
        var table = layui.table
            ,layer=layui.layer
            ,laydate=layui.laydate
            ,upload=layui.upload
            ,form=layui.form
            ,element = layui.element;
        $(document).ready(function(){
            form.render();
        });
        settlementTable = table.render({
            elem: '#Settlement'
            ,url:"/ResultManagement/gradingList?pageSize=10&useFlag=true"
            ,cols: [[
                {type:'checkbox'}
                ,{field:'planName', title: '计划名称', align: 'center'}
                ,{field:'deptName', title: '科室', align: 'center'}
                ,{field:'userName', title: '姓名', align: 'center'} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                ,{field:'filingTime', title: '备案时间', align: 'center'}
                ,{field:'xszz', title: '学术著作(数)', align: 'center'}
                ,{field:'xslw', title: '学术论文(数)', align: 'center'}
                ,{field:'xsltztfy', title: '学术论坛主题发言(数)', align: 'center'}
                ,{field:'jtcg', title: '结题成果(数)', align: 'center'}
                ,{field:'pxhj', title: '评选获奖(数)', align: 'center'}
                ,{field:'trOther', title: '认定(数)', align: 'center',templet:function (d) {
                    if(d.trOther == undefined || d.trOther == "undefined" || d.trOther == "" || d.trOther == null){
                        d.trOther = "无"
                    }else{
                        d.trOther = d.trOther;
                    }
                    var str= d.xszz + d.xslw + d.xsltztfy + d.jtcg + d.pxhj + "/" + d.trOther;
                        return str
                    }}
                ,{field: 'type', title: '审核',width:120, toolbar: '#barDemo'}
            ]],
            page:true
            ,parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": 0, //解析接口状态
                    "count": res.totleNum, //解析数据长度
                    "data": res.obj //解析数据列表
                }
            },
            done:function (res) {

            }
        });
        nosettlementTable = table.render({
            elem: '#noSettlement'
            ,url:"/ResultManagement/gradingList?type=1&pageSize=10&useFlag=true"
            ,cols: [[
                {type:'checkbox'}
                ,{field:'planName', title: '计划名称', align: 'center'}
                ,{field:'deptName', title: '科室', align: 'center'}
                ,{field:'userName', title: '姓名', align: 'center'} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                ,{field:'filingTime', title: '备案时间', align: 'center'}
                ,{field:'xszz', title: '学术著作(数)', align: 'center'}
                ,{field:'xslw', title: '学术论文(数)', align: 'center'}
                ,{field:'xsltztfy', title: '学术论坛主题发言(数)', align: 'center'}
                ,{field:'jtcg', title: '结题成果(数)', align: 'center'}
                ,{field:'pxhj', title: '评选获奖(数)', align: 'center'}
                ,{field:'trOther', title: '认定(数)', align: 'center',templet:function (d) {
                        if(d.trOther == undefined || d.trOther == "undefined" || d.trOther == "" || d.trOther == null){
                            d.trOther = "无"
                        }else{
                            d.trOther = d.trOther;
                        }
                        var str= d.xszz + d.xslw + d.xsltztfy + d.jtcg + d.pxhj + "/" + d.trOther;
                        return str
                    }}
                ,{field: 'type', title: '审核',width:120, toolbar: '#barDemo'}
            ]],
            page:true
            ,parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": 0, //解析接口状态
                    "count": res.totleNum, //解析数据长度
                    "data": res.obj //解析数据列表
                }
            },
            done:function (res) {

            }
        });

        $("#export").click(function(){
            var txt = $("#ulBox").find("li.layui-this").html();
            if(txt == "未确定"){
                var type = "2"
            }
            if(txt == "已确定"){
                var type = "5"
            }
            window.location.href = '/ResultManagement/examineExport?type='+type
        });
        //页签切换监听事件
        element.on('tab(tabGolle)', function(data){
            if(data.index==0){
                $("#commit").css("display","inline-block");
                table.reload("Settlement",{
                    url: "/ResultManagement/gradingList?pageSize=10&useFlag=true"
                })
            }else if(data.index==1){
                $("#commit").css("display","none");
                table.reload("noSettlement",{
                    url: "/ResultManagement/gradingList?type=1&pageSize=10&useFlag=true"
                })
            }
        });
        //监听行工具事件
        table.on('tool(SettlementFilter)', function(obj){
            var data = obj.data;
            var trId = data.trId;
            if(obj.event === 'edit'){
                layer.open({
                    type: 1 //此处以iframe举例
                    , title: '编辑认定等级'
                    , area: ['550px', '300px']
                    , content: '<form class="layui-form" id="autoproject" action="">' +
                    '<div class="one" style="margin-top: 12px;">' +
                    '<div class="layui-form-item" id="cdwz" style="margin-bottom:15px;">' +
                    '<label class="layui-form-label" style="width: 120px;"><span style="color: red;">*</span>认定等级：</label>' +
                    '<div class="layui-input-inline" style="width:57.5% ;">' +
                    '<select name="trOther" id="trOther" autocomplete="off"  class="layui-select">' +
                    '<option value="SELECTION_LEVEL1">金奖</option><option value="SELECTION_LEVEL2">银奖</option ><option value="SELECTION_LEVEL3">铜奖</option><option value="SELECTION_LEVEL">无</option>'+
                    '</select></div>' +
                    '</div>' +
                    '</div>' +
                    '</form>'
                    , btn: ['确定']
                    ,success: function (res) {
                        form.render();
                    }
                    , yes: function (index, layero) {
                        layer.closeAll();
                        var trOtherVal = $("#trOther").next(".layui-form-select").find("dl dd.layui-this").attr("lay-value");
                        var trOther = $("#trOther").next(".layui-form-select").find("dl dd.layui-this").text();
                        $.ajax({
                            type: "post",
                            url: "/ResultManagement/cognizance",
                            dataType: "json",
                            data: {
                                trId: trId,
                                trOther:trOther
                            },
                            success: function (res) {
                                if (res.flag) {
                                    layer.msg("修改成功");
                                    settlementTable.reload();
                                } else {
                                    layer.msg(res.msg);
                                }
                            }
                        })
                    }
                });
            }
            else if(obj.event === 'look'){
                window.location.href='/rpmPlan/lookreview?type=4&btype=look&userId='+data.userId+'&planId='+data.planId
            }
        });
        //监听行工具事件
        table.on('tool(noSettlementFilter)', function(obj){
            var data = obj.data;
            var trId = data.trId;
            if(obj.event === 'edit'){
                layer.open({
                    type: 1 //此处以iframe举例
                    , title: '编辑认定等级'
                    , area: ['550px', '300px']
                    , content: '<form class="layui-form" id="autoproject" action="">' +
                    '<div class="one" style="margin-top: 12px;">' +
                    '<div class="layui-form-item" id="cdwz" style="margin-bottom:15px;">' +
                    '<label class="layui-form-label" style="width: 120px;"><span style="color: red;">*</span>认定等级：</label>' +
                    '<div class="layui-input-inline" style="width:57.5% ;">' +
                    '<select name="trOther" id="trOther" autocomplete="off"  class="layui-select">' +
                    '<option value="SELECTION_LEVEL1">金奖</option><option value="SELECTION_LEVEL2">银奖</option ><option value="SELECTION_LEVEL3">铜奖</option><option value="SELECTION_LEVEL">无</option>'+
                    '</select></div>' +
                    '</div>' +
                    '</div>' +
                    '</form>'
                    , btn: ['确定']
                    ,success: function (res) {
                        form.render();
                    }
                    , yes: function (index, layero) {
                        layer.closeAll();
                        var trOtherVal = $("#trOther").next(".layui-form-select").find("dl dd.layui-this").attr("lay-value");
                        var trOther = $("#trOther").next(".layui-form-select").find("dl dd.layui-this").text();
                        $.ajax({
                            type: "post",
                            url: "/ResultManagement/cognizance",
                            dataType: "json",
                            data: {
                                trId: trId,
                                trOther:trOther
                            },
                            success: function (res) {
                                if (res.flag) {
                                    layer.msg("修改成功");
                                    settlementTable.reload();
                                } else {
                                    layer.msg(res.msg);
                                }
                            }
                        })
                    }
                });
            }
            else if(obj.event === 'look'){
                window.location.href='/rpmPlan/lookreview?type=4&btype=look&userId='+data.userId+'&planId='+data.planId
            }
        });
        //确定名单操作
        $("#commit").click(function(){
            var data = table.checkStatus('Settlement').data;
            if (data.length == 0 || data.length < 0) {
                layer.msg("请选择一条或者多条进行审核");
                return false;
            } else if (data.length > 0) {
                var topicId = "";
                var trId = "";
                for(var i=0;i<data.length;i++){
                    trId += data[i].trId + ","
                }
                layer.confirm('是否确认名单', {
                    btn: ['确认', '取消'],
                    icon: 7,
                    title: "系统提示"
                }, function () {
                    $.ajax({
                        type: "post",
                        url: "/ResultManagement/determine",
                        dataType: "json",
                        data: {
                            trIds: trId
                        },
                        success: function (res) {
                            if (res.flag) {
                                layer.msg("名单成功确认");
                                settlementTable.reload();
                            } else {
                                layer.msg(res.msg);
                            }
                        }
                    })
                }, function () {
                    layer.closeAll();
                });
            }
        })


        // //页签切换监听事件 导出
        // element.on('tab(tabGolle)', function(data){
        //     if(data.index==0){
        //         $("#export").click(function(){
        //             window.location.href = '/rpmTopic/getExportdocument';
        //         });
        //     }else if(data.index==1){
        //         $("#export").click(function(){
        //             window.location.href = '/rpmTopic/getExportdocument?type=1';
        //         });
        //     }
        // });
    })
</script>
</html>
